<template>
	<view>
		<navbar mode="normal" title="搜索结果"></navbar>
		<view class="content" v-if="canshow">
			<view class="none" v-if="goodsList.length == 0">啥也没搜到哦，换个关键字试试吧~</view>
			<view class="list" v-else>
				<goods-full-card-list :goodsList="goodsList" :notifyNoMore="true"></goods-full-card-list>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList:[],
				canshow:false
			};
		},
		onLoad(data) {
			uni.showLoading({
			})
			var vue = this
			this.$request("goods/getAll",{},function(res){
				var index = 0
				var allGoods = res.data.data
				//筛选搜索的商品
				for(var i in allGoods){
					if(allGoods[i].title.indexOf(data.text) >= 0){
						vue.$set(vue.goodsList,index,allGoods[i])
					}
				}
				/* console.log(data.text);
				console.log(allGoods);
				console.log(vue.goodsList); */
				vue.canshow = true
				uni.hideLoading()
			})
		}
	}
</script>

<style lang="scss">
	.content{
		display: flex;
		flex-direction: column;
		align-items: center;
		.none{
			font-size: 30rpx;
			margin-top: 20rpx;
			color: $my-main-color;
		}
	}
</style>
